package com.legendary.awesome;

import java.util.HashMap;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ContactsActivityList extends ListActivity {
	String activity_list[] = {"Add Contact"};
	HashMap<String, String> map = new HashMap<String, String>();
	
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		populateHMap();
		setListAdapter(new ArrayAdapter<String>(ContactsActivityList.this, android.R.layout.simple_list_item_1, activity_list));
	}
	
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id)
	{
		super.onListItemClick(l, v, position, id);
		
		String selected_activity = activity_list[position];
		
		Class myClass = null;
		
		try
		{
			myClass = Class.forName(map.get(selected_activity));
			Intent intent = new Intent(ContactsActivityList.this, myClass);
			startActivity(intent);
		} catch (ClassNotFoundException e)
		{
			e.printStackTrace();
		}
	}
	
	public void populateHMap()
	{
		map.put("Add Contact", "com.legendary.awesome.RegisterContact");
		map.put("View Contact", "com.legendary.awesome.ViewContactsInfo");
	}
}
